package com.bsh.serviceImpl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bsh.mybatis.model.UserBank;
import com.bsh.repository.DaoUserBank;
import com.bsh.service.UserBankService;

/**
 * 用户银行
 * 
 *
 */
@Service
@Transactional
public class UserBankServiceImpl implements UserBankService {
	@Autowired
	private DaoUserBank ubDao;
	
	/* (non-Javadoc)
	 * @see com.bsh.serviceImpl.UserBankService#addUserBank(com.bsh.mybatis.model.UserBank)
	 */
	@Override
	public Integer addUserBank(UserBank ubReq) {
		return ubDao.addUserBank(ubReq);
	}
	
	
	
	@Override
	public  List<Map<String, Object>> getMyBankList(Integer userid){
		return ubDao.queryMyBankList(userid);
	}

	@Override
	public List<Map<String, Object>> selectByBankCard(String bankCard) {
		return ubDao.selectByBankCard(bankCard);
	}

	/**
	 * 查询用户的某张银行卡
	 * @param record
	 * @return
	 */	
	@Override
	public UserBank selectUserOneBankCard(Integer bankCardId,Integer userId){
		return ubDao.selectUserOneBankCard(bankCardId, userId);
	}


    /**
     * 标记删除银行卡
     */
	@Override
	public Integer deleteUserOneBankCard(Integer bankCardId, Integer userId) {
		UserBank ub=ubDao.selectUserOneBankCard(bankCardId, userId);
		ub.setStatus((short) 0);
		return ubDao.updateByPrimaryKey(ub);
	}



	@Override
	public Integer countBankCards(Integer userId, Integer isMerchant) {
		return ubDao.queryMyCardsNumber(userId,isMerchant);
	}

	
	 
}
